home *** CD-ROM | disk | FTP | other *** search
/ Bath / Bath CDROM.iso / pc / MAP.DXR / 00008_pointAwayFromMiddle.ls < prev    next >
Encoding:
Text File  |  2001-07-26  |  928 b   |  47 lines

  1. property mySprite, myFixedPoint
  2.  
  3. on beginSprite me
  4.   mySprite = sprite(me.spriteNum)
  5.   theMember = mySprite.member
  6.   memberType = theMember.type
  7.   stageWidth = the stageRight - the stageLeft
  8.   stageHeight = the stageBottom - the stageTop
  9.   myFixedPoint = point(stageWidth, stageHeight) / 2
  10. end
  11.  
  12. on prepareFrame me
  13.   slope = myFixedPoint - mySprite.loc
  14.   angle = GetAngle(me, slope)
  15.   if mySprite.rotation <> angle then
  16.     mySprite.rotation = angle
  17.   end if
  18. end
  19.  
  20. on GetAngle me, slope
  21.   dH = slope[1]
  22.   dV = slope[2]
  23.   if dH then
  24.     slope = float(dV) / dH
  25.     angle = atan(slope)
  26.     if dH < 0 then
  27.       angle = angle + PI
  28.     end if
  29.   else
  30.     if dV > 0 then
  31.       angle = PI / 2
  32.     else
  33.       if dV < 0 then
  34.         angle = 3 * PI / 2
  35.       else
  36.         angle = 0
  37.       end if
  38.     end if
  39.   end if
  40.   angle = angle * 180 / PI
  41.   return angle
  42. end
  43.  
  44. on getMag me, slope
  45.   return sqrt(power(slope[1], 2) + power(slope[2], 2))
  46. end
  47.